package ma.ensao.action;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import org.apache.commons.io.FileUtils;
import org.omg.CORBA.portable.InputStream;

import com.opensymphony.xwork2.ActionSupport;
import java.lang.reflect.*;

public class FileUploadAction extends ActionSupport{

	private File fileUpload;
	private String fileUploadContentType;
	private String fileUploadFileName;

	public String getFileUploadContentType() {
		return fileUploadContentType;
	}

	public void setFileUploadContentType(String fileUploadContentType) {
		this.fileUploadContentType = fileUploadContentType;
	}

	public String getFileUploadFileName() {
		return fileUploadFileName;
	}

	public void setFileUploadFileName(String fileUploadFileName) {
		this.fileUploadFileName = fileUploadFileName;
	}

	public File getFileUpload() {
		return fileUpload;
	}

	public void setFileUpload(File fileUpload) {
		this.fileUpload = fileUpload;
	}

	public String execute() throws Exception{
		ZipFile zf = new ZipFile(fileUpload);
		Enumeration<? extends ZipEntry> enumu = zf.entries();
		
		while(enumu.hasMoreElements()) {
			ZipEntry entry=(ZipEntry)enumu.nextElement();
			String dest=entry.getName();
			System.out.println("Unzipping " + entry.getName());

	
		      InputStream in = (InputStream) zf.getInputStream(entry);
		}
		
		return SUCCESS;
	
	
	}
	
	public String display() {
		return NONE;
	}
	
}